package com.springboot.springautowired.javaDesignModel.proxyModel;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class DynamicOperation {
    public static void operation() {
        DynamicSubject subject = new DynamicSubjectImpl();
        InvocationHandler handlerClass = new InvocationHandlerClass(subject);
        //jdk动态代理的第二个必要因素，Proxy类
        DynamicSubject dynamicSubject = (DynamicSubject) Proxy.newProxyInstance(subject.getClass().getClassLoader(), subject.getClass().getInterfaces(), handlerClass);
        dynamicSubject.hello("把头甩甩大步的走开");
        dynamicSubject.bye();
    }
}
